
<template>
  <div style="height: 100%; width: 100%; position: relative">
      <div class="pagetop">
          <div class="search-title">快速查询</div>
          <el-input v-model="txtsearch" placeholder="请输入代码|名称" style="width: 200px" @keyup.enter.native="searchdata"></el-input>
          <div class="top-deal">
              <el-button @click="InitTabPage" icon="el-icon-search" type="primary" v-has="'PINQUERY'" :disabled="changeflag">查询</el-button>
              <el-button @click="btnSave" icon="el-icon-document" v-has="'PMATCH'" :disabled="!changeflag">保存</el-button>
              <el-button @click="btnCancel" icon="el-icon-close" :disabled="!changeflag">取消</el-button>
              <el-button @click="btnset" icon="el-icon-setting">设置</el-button>
              <el-button @click="btnContrast" v-has="'PMATCH'" >智能对照</el-button>
          </div>
      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <el-tabs v-model="TabSheet" @tab-click="ResultTabClick" style="height: 100%" type="border-card" ref="tabs" class="Tabundefined RMTab ResultGerm">
                  <el-tab-pane label="标本类型" name="1" style="height: 100%">
                      <vxe-table ref="xTable1" :data.sync="tableData1" :loading="loading" :keyboard-config="keyConfig" :row-class-name="rowClassName1" :select-config="selectConfig" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytablestyle" highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="45" align="center"></vxe-table-column>
                          <vxe-table-column field="specimen_code" title="标本类型代码" width="100"></vxe-table-column>
                          <vxe-table-column field="specimen_name" title="标本类型名称" width="100"></vxe-table-column>
                          <vxe-table-column field="carss_codename" title="耐药网代码(双击弹窗)" width="200" :edit-render="{ name: 'input', autoselect: true }" :formatter="format">
                              <template v-slot:edit="{ row }">
                                  <el-input v-model="row.carss_coden" style="width: 100%" @dblclick.native="opendialog(row, 0)" @change="chanrgename($event, row)" readonly clearable> </el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="specimen_enname" title="英文名称" width="100"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="拼音码" width="100"></vxe-table-column>
                      </vxe-table>
                  </el-tab-pane>
                  <el-tab-pane label="细菌" name="2" style="height: 100%" :key="'germ_' + tablekey">
                      <vxe-table ref="xTable2" :data.sync="tableData2" :loading="loading" :keyboard-config="keyConfig" :row-class-name="rowClassName2" :select-config="selectConfig" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytablestyle" highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="45" align="center"></vxe-table-column>
                          <!-- <vxe-table-column field="itemclasscode" title="项目归类" width="150" :formatter="format"></vxe-table-column> -->
                          <vxe-table-column field="rpt_itemcode" title="项目代码" width="100"></vxe-table-column>
                          <vxe-table-column field="rpt_itemname" title="项目名称" width="200"></vxe-table-column>
                          <!-- <vxe-table-column field="carss_coden" title="耐药网代码" width="100"></vxe-table-column> -->
                          <vxe-table-column field="carss_codename" title="耐药网代码(双击弹窗)" width="250" :edit-render="{ name: 'input', autoselect: true }" :formatter="format">
                              <template v-slot:edit="{ row }">
                                  <el-input v-model="row.carss_coden" style="width: 100%" @dblclick.native="opendialog(row, 1)" @change="chanrgename($event, row)" readonly clearable> </el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="itemcode_en" title="英文缩写" width="115"></vxe-table-column>
                          <vxe-table-column field="itemname_en" title="英文名称" width="175"></vxe-table-column>
                          <!-- <vxe-table-column field="germflag" title="细菌标志" width="100" :formatter="format"></vxe-table-column> -->
                      </vxe-table>
                  </el-tab-pane>
                  <el-tab-pane label="抗生素" name="3" style="height: 100%" :key="'med_' + tablekey">
                      <vxe-table ref="xTable3" :data.sync="tableData3" :loading="loading" :keyboard-config="keyConfig" :row-class-name="rowClassName3" :select-config="selectConfig" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytablestyle" highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="45" align="center"></vxe-table-column>
                          <vxe-table-column field="medcode" title="药物代码" width="100"></vxe-table-column>
                          <vxe-table-column field="medname" title="药物名称" width="140"></vxe-table-column>
                          <vxe-table-column field="medname_en" title="药物英文" width="140"></vxe-table-column>
                          <vxe-table-column field="carss_codename" title="耐药网代码(双击弹窗)" width="200" :edit-render="{ name: 'input', autoselect: true }" :formatter="format">
                              <template v-slot:edit="{ row }">
                                  <el-input v-model="row.carss_coden" style="width: 100%" @dblclick.native="opendialog(row, 2)" @change="chanrgename($event, row)" readonly clearable> </el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="inputcode" title="录入码" width="100"></vxe-table-column>
                          <vxe-table-column field="stopflag" title="停用" width="100" align="center">
                              <template v-slot="{ row }">
                                  <el-checkbox v-model="row.stopflag" true-label="1" false-label="0" disabled></el-checkbox>
                              </template>
                          </vxe-table-column>
                      </vxe-table>
                  </el-tab-pane>
                  <el-tab-pane label="科室" name="4" style="height: 100%" :key="'dept_' + tablekey">
                      <vxe-table ref="xTable4" :data.sync="tableData4" :loading="loading" :keyboard-config="keyConfig" :row-class-name="rowClassName4" :select-config="selectConfig" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytablestyle" highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="45" align="center"></vxe-table-column>
                          <vxe-table-column field="deptno" title="科室代码" width="70"></vxe-table-column>
                          <vxe-table-column field="deptname" title="科室名称" width="120"></vxe-table-column>
                          <vxe-table-column field="deptenname" title="英文名称" width="100"></vxe-table-column>
                          <vxe-table-column field="carss_codename" title="耐药网代码(双击弹窗)" width="200" :edit-render="{ name: 'input', autoselect: true }" :formatter="format">
                              <template v-slot:edit="{ row }">
                                  <el-input v-model="row.carss_coden" style="width: 100%" @dblclick.native="opendialog(row, 3)" @change="chanrgename($event, row)" readonly clearable> </el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="depttype" title="科室类型" width="75"></vxe-table-column>
                          <!-- <vxe-table-column field="deptsubject" title="专业类别" width="75"></vxe-table-column> -->
                          <vxe-table-column field="his_deptno" title="科室代码(his)" width="90"></vxe-table-column>
                          <vxe-table-column field="hospcode" title="所属院区" width="100"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="拼音码" width="100"></vxe-table-column>
                          <vxe-table-column field="invalidflag" title="停用" width="45" align="center">
                              <template v-slot="{ row }">
                                  <el-checkbox v-model="row.invalidflag" true-label="1" false-label="0" disabled></el-checkbox>
                              </template>
                          </vxe-table-column>
                      </vxe-table>
                  </el-tab-pane>
                  <el-tab-pane label="仪器" name="5" style="height: 100%" :key="'ins_' + tablekey">
                      <vxe-table ref="xTable5" :data.sync="tableData5" :loading="loading" :keyboard-config="keyConfig" :row-class-name="rowClassName5" :select-config="selectConfig" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytablestyle" highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="45" align="center"></vxe-table-column>
                          <!-- <vxe-table-column field="labgroupid" title="所属检验组" width="100"></vxe-table-column>
                          <vxe-table-column field="instrid" title="仪器id" width="70"></vxe-table-column>
                          <vxe-table-column field="instrclass" title="仪器大类" width="100"></vxe-table-column> -->
                          <vxe-table-column field="instrno" title="仪器代号" width="100"></vxe-table-column>
                          <vxe-table-column field="instrname" title="仪器名称" width="170"></vxe-table-column>
                          <vxe-table-column field="carss_codename" title="耐药网代码(双击弹窗)" width="200" :edit-render="{ name: 'input', autoselect: true }" :formatter="format">
                              <template v-slot:edit="{ row }">
                                  <el-input v-model="row.carss_coden" style="width: 100%" @dblclick.native="opendialog(row, 4)" @change="chanrgename($event, row)" readonly clearable> </el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="instrserial" title="仪器型号" width="170"></vxe-table-column>
                          <!-- <vxe-table-column field="rptunitid" title="对应报告单元" width="100"></vxe-table-column>
                          <vxe-table-column field="instrna" title="仪器简称" width="200"></vxe-table-column> -->
                          <!-- <vxe-table-column field="his_code" title="his代码" width="100"></vxe-table-column> -->
                          <vxe-table-column field="inuse" title="在用" width="45" align="center">
                              <template v-slot="{ row }">
                                  <el-checkbox v-model="row.inuse" true-label="1" false-label="0" disabled></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="stop_dt" title="停用时间" width="100"></vxe-table-column>
                      </vxe-table>
                  </el-tab-pane>
                  <!-- <el-tab-pane label="药敏卡" name="6" style="height: 100%" :key="tablekey">
                      <vxe-table ref="xTable6" :data.sync="tableData6" :loading="loading" :keyboard-config="keyConfig" :row-class-name="rowClassName6" :select-config="selectConfig" :sort-config="{ trigger: 'cell' }" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" border fit height="auto" header-align="center" highlight-current-row highlight-hover-row class="mytablestyle" highlight-hover-column resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe>
                          <vxe-table-column type="index" title="NO." width="45" align="center"></vxe-table-column>
                          <vxe-table-column field="lathname" title="仪器板条名称" width="125"></vxe-table-column>
                          <vxe-table-column field="testgroupno" title="试验组合名称" width="125"></vxe-table-column>
                          <vxe-table-column field="testgroupname" title="试验组合代码" width="125"></vxe-table-column>
                          <vxe-table-column field="carss_codename" title="耐药网代码(双击弹窗)" width="200" :edit-render="{ name: 'input', autoselect: true }" :formatter="format">
                              <template v-slot:edit="{ row }">
                                  <el-input v-model="row.carss_codename" style="width: 100%" @dblclick.native="opendialog(row, 5)" readonly> </el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="instrno" title="默认仪器代码" width="100"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="录入码" width="100"></vxe-table-column>
                          <vxe-table-column field="defpanelno" title="板条默认批号" width="100"></vxe-table-column>
                      </vxe-table>
                  </el-tab-pane> -->
              </el-tabs>
          </div>
      </div>

      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="中间件数据库连接设置" :visible.sync="dialogSetting" width="500px">
          <div style="position: relative; width: 100%; text-align: center">
              <table style="border: 1px solid #ffffff; width: 80%; margin: auto">
                  <tr class="trstyle">
                      <!-- <td class="tdstyle1">1901</td> -->
                      <td class="tdstyle2">数据库类型</td>
                      <td style="text-align: left">
                          <el-select placeholder="请选择" style="width: 100%; margin-left: 10px" v-model="dbms">
                              <el-option key="1" label="Sqlserver" value="1"></el-option>
                              <el-option key="2" label="mySql" value="2"></el-option>
                          </el-select>
                          <!-- <el-input style="width: 100%; margin-left: 10px" v-model="dbms"></el-input> -->
                      </td>
                  </tr>
                  <tr class="trstyle">
                      <!-- <td class="tdstyle1">1902</td> -->
                      <td class="tdstyle2">数据库地址</td>
                      <td style="text-align: left">
                          <el-input style="width: 100%; margin-left: 10px" v-model="Server"></el-input>
                      </td>
                  </tr>
                  <tr class="trstyle">
                      <!-- <td class="tdstyle1">1903</td> -->
                      <td class="tdstyle2">数据库名</td>
                      <td style="text-align: left">
                          <el-input style="width: 100%; margin-left: 10px" v-model="DataBase"></el-input>
                      </td>
                  </tr>
                  <tr class="trstyle">
                      <!-- <td class="tdstyle1">1904</td> -->
                      <td class="tdstyle2">用户名</td>
                      <td style="text-align: left">
                          <el-input style="width: 100%; margin-left: 10px" v-model="Logid"></el-input>
                      </td>
                  </tr>
                  <tr class="trstyle">
                      <!-- <td class="tdstyle1">1905</td> -->
                      <td class="tdstyle2">密码</td>
                      <td style="text-align: left">
                          <el-input style="width: 100%; margin-left: 10px" v-model="Password"></el-input>
                      </td>
                  </tr>
                  <!-- <tr class="trstyle">
                      <td class="tdstyle1">1906</td>
                      <td class="tdstyle2">DbParm</td>
                      <td style="text-align: left">
                          <el-input style="width: 100%; margin-left: 10px" v-model="DbParm"></el-input>
                      </td>
                  </tr> -->
                  <tr style="height: 50px">
                      <td colspan="3" style="text-align: center">
                          <el-button style="width: 80px" @click="dialogflag_saveevent">保存</el-button>
                          <el-button style="width: 80px" @click="dialogflag_cancelevent">取消</el-button>
                          <el-button style="width: 80px" @click="dialogflag_testevent">测试连接</el-button>
                      </td>
                  </tr>
              </table>
          </div>
      </el-dialog>
      <el-dialog width="1000px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="选择耐药网" :visible.sync="drn_itemdialog" :destroy-on-close="true">
          <rm-pop-common v-if="this.isshow == '0'" @change="drnitemchange" @cancel="drn_itemdialog = false" datatype="LIS813_specimen"></rm-pop-common>
          <rm-pop-common v-show="this.isshow == '1'" @change="drnitemchange" @cancel="drn_itemdialog = false" datatype="LIS813_germ"></rm-pop-common>
          <rm-pop-common v-show="this.isshow == '2'" @change="drnitemchange" @cancel="drn_itemdialog = false" datatype="LIS813_med"></rm-pop-common>
          <rm-pop-common v-show="this.isshow == '3'" @change="drnitemchange" @cancel="drn_itemdialog = false" datatype="LIS813_dept"></rm-pop-common>
          <rm-pop-common v-show="this.isshow == '4'" @change="drnitemchange" @cancel="drn_itemdialog = false" datatype="LIS813_instrument"></rm-pop-common>
          <!-- <rm-pop-common v-show="this.isshow == '5'" @change="drnitemchange" @cancel="drn_itemdialog = false" datatype="LIS813_med_panel"></rm-pop-common> -->
      </el-dialog>
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="智能对照结果" :visible.sync="dialogcontrast" width="350px">
          <div style="position: relative; width: 100%">
              <table style="border: 1px solid #ffffff; width: 80%; margin: auto">
                  <tr>
                      <td style="text-align: right; width: 200px">【标本类型】自动对照的共计:</td>
                      <td style="text-align: left">
                          <span style="color: blue">{{ this.specimenNum }}</span
                          >个
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align: right; width: 200px">【细菌】自动对照的共计:</td>
                      <td style="text-align: left">
                          <span style="color: blue">{{ this.germNum }}</span
                          >个
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align: right; width: 200px">【抗生素】自动对照的共计:</td>
                      <td style="text-align: left">
                          <span style="color: blue">{{ this.medNum }}</span
                          >个
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align: right; width: 200px">【科室】自动对照的共计:</td>
                      <td style="text-align: left">
                          <span style="color: blue">{{ this.deptNum }}</span
                          >个
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align: right; width: 200px">【仪器】自动对照的共计:</td>
                      <td style="text-align: left">
                          <span style="color: blue">{{ this.instrumentNum }}</span
                          >个
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align: right; width: 200px">【药敏卡】自动对照的共计:</td>
                      <td style="text-align: left">
                          <span style="color: blue">{{ this.medpanelNum }}</span
                          >个
                      </td>
                  </tr>
                  <tr>
                      <td style="height: 30px" colspan="2">现在是否保存数据？</td>
                  </tr>

                  <tr style="height: 50px">
                      <td colspan="3" style="text-align: center">
                          <el-button style="width: 80px" @click="dialogcontrast_save">保存</el-button>
                          <el-button style="width: 80px" @click="dialogcontrast_cancel">取消</el-button>
                      </td>
                  </tr>
              </table>
          </div>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
import XLSX from "xlsx";
import FileSaver from "file-saver";
export default {
  name: "LIS813",
  data() {
      return {
          keyConfig: {
              isDel: false,
              isTab: true,
              isEdit: true,
              isArrow: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          selectConfig: { tigger: "row" },
          tableData: [],
          // buttonwidth: 0,
          loading: false,
          changeflag: false,
          isFirstLoading: false,
          dialogReqItem: false,
          TabSheet: "1",
          tableData1: [],
          tableData2: [],
          tableData3: [],
          tableData4: [],
          tableData5: [],
          tableData6: [],
          oldtableData1: [],
          oldtableData2: [],
          oldtableData3: [],
          oldtableData4: [],
          oldtableData5: [],
          oldtableData6: [],
          rptitemclassOption: [],
          specimentypeOption: [],
          dialogSetting: false,
          dbms: "",
          Server: "",
          DataBase: "",
          Logid: "",
          Password: "",
          DbParm: "",
          drn_itemdialog: false,
          selrow: {},
          isshow: "0",
          specimenOption: [], // 耐药网标本类型
          germOption: [], // 耐药网细菌
          medOption: [], // 耐药网抗生素
          deptOption: [], // 耐药网科室
          instrumentOption: [], // 耐药网仪器
          medpanelOption: [], // 耐药网药敏卡
          dialogcontrast: false,
          specimenNum: 0,
          germNum: 0,
          medNum: 0,
          deptNum: 0,
          instrumentNum: 0,
          medpanelNum: 0,
          txtsearch: "",
          tablekey: 0,
          oldtabno: 0,
      };
  },
  created() {},
  mounted() {
      this.initOption(); //初始化主列表
      this.InitTabPage();
  },
  updated() {},
  methods: {
      ResultTabClick(tab) {
          console.info("tab====" + tab.index);
          this.isshow = tab.index;
          this.savetabdata(this.oldtabno, tab.index);
          this.tablekey++;
      },
      chanrgename(value, row) {
           if(value === "")  {
              this.selrow = row;
              this.selrow.carss_coden = "";
              this.selrow.carss_codename = " ";
          }
          this.changeflag = true;
      },
      initOption() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS813",
                  method: "post",
                  data: {
                      action: "initOption",
                  },
              })
              .then((res) => {
                  this.rptitemclassOption = res.rptitemclassOption;
                  this.specimentypeOption = res.specimentypeOption;
                  this.dbms = res.dbms;
                  this.Server = res.server;
                  this.DataBase = res.database;
                  this.Logid = res.logid;
                  this.Password = res.password;
                  this.DbParm = res.dbparm;
                  this.loading = false;
                  this.specimenOption = res.specimenOption;
                  this.germOption = res.germOption;
                  this.medOption = res.medOption;
                  this.deptOption = res.deptOption;
                  this.instrumentOption = res.instrumentOption;
                  this.medpanelOption = res.medpanelOption;
              })
              .catch((err) => {
                  this.loading = false;
              });
      },

      InitPage() {
          this.txtsearch = "";
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS813",
                  method: "post",
                  data: {
                      action: "InitPage",
                  },
              })
              .then((res) => {
                  this.tableData1 = res.specimenlist;
                  this.tableData2 = res.labrptitemlist;
                  this.tableData3 = res.labmedlist;
                  this.tableData4 = res.dcdeptlist;
                  this.tableData5 = res.labinstrumentlist;
                  this.tableData6 = res.bacttestgrouplist;
                  this.oldtableData1 = res.specimenlist;
                  this.oldtableData2 = res.labrptitemlist;
                  this.oldtableData3 = res.labmedlist;
                  this.oldtableData4 = res.dcdeptlist;
                  this.oldtableData5 = res.labinstrumentlist;
                  this.oldtableData6 = res.bacttestgrouplist;
                  this.loading = false;
              })
              .catch((err) => {
                  this.loading = false;
              });
      },
      // 查询当前页签的数据
      InitTabPage() {
          this.txtsearch = "";
          this.loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS813",
                  method: "post",
                  data: {
                      action: "InitTabPage",
                      tabno: this.isshow,
                  },
              })
              .then((res) => {
                  switch (parseInt(this.isshow)) {
                      case 0:
                          this.tableData1 = res.datalist;
                          this.oldtableData1 = res.datalist;
                          break;
                      case 1:
                          this.tableData2 = res.datalist;
                          this.oldtableData2 = res.datalist;
                          break;
                      case 2:
                          this.tableData3 = res.datalist;
                          this.oldtableData3 = res.datalist;
                          break;
                      case 3:
                          this.tableData4 = res.datalist;
                          this.oldtableData4 = res.datalist;
                          break;
                      case 4:
                          this.tableData5 = res.datalist;
                          this.oldtableData5 = res.datalist;
                          break;
                      default:
                          this.tableData6 = res.datalist;
                          this.oldtableData6 = res.datalist;
                          break;
                  }

                  this.loading = false;
              })
              .catch((err) => {
                  this.loading = false;
              });
      },
      activeMethod({ row }) {
          return true;
      },
      rowClassName1({ row, rowIndex }) {
          let isDirty = this.$refs.xTable1.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable1.hasRowInsert(row)) {
              return "row-new";
          }
      },
      rowClassName2({ row, rowIndex }) {
          let isDirty = this.$refs.xTable2.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable2.hasRowInsert(row)) {
              return "row-new";
          }
      },
      rowClassName3({ row, rowIndex }) {
          let isDirty = this.$refs.xTable3.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable3.hasRowInsert(row)) {
              return "row-new";
          }
      },
      rowClassName4({ row, rowIndex }) {
          let isDirty = this.$refs.xTable4.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable4.hasRowInsert(row)) {
              return "row-new";
          }
      },
      rowClassName5({ row, rowIndex }) {
          let isDirty = this.$refs.xTable5.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable5.hasRowInsert(row)) {
              return "row-new";
          }
      },
      rowClassName6({ row, rowIndex }) {
          let isDirty = this.$refs.xTable6.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable6.hasRowInsert(row)) {
              return "row-new";
          }
      },

      btnCancel() {
          this.$confirm("您确定要取消这次改动吗？", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  this.isFirstLoading = true;
                  this.changeflag = false;
                  this.InitTabPage();
              })
              .catch(() => {});
      },

      hasChange() {
          this.changeflag = true;
      },
      ddlChange() {
          this.changeflag = true;
      },

      qpurposechange(code, name) {
          this.purposeno = code;
          this.InitPage();
      },

      format({ cellValue, row, column }) {
          if (column.property == "specimentype") {
              var optionitem = this.specimentypeOption.find((m) => m.codeno == row.specimentype);
              if (optionitem != null) {
                  return optionitem.codena;
              } else {
                  return "";
              }
          }
          if (column.property == "germflag") {
              if (row.germflag == "2") {
                  return "致病菌";
              } else if (row.germflag == "3") {
                  return "正常菌种";
              } else {
                  return cellValue;
              }
          }
          if (column.property == "itemclasscode") {
              var optionitem = this.rptitemclassOption.find((m) => m.itemclasscode == row.itemclasscode);
              if (optionitem != null) {
                  return optionitem.itemclassname;
              } else {
                  return "";
              }
          }
          if (column.property == "carss_codename") {
              var sOption = [];
              switch (row.tableflag) {
                  case "1": // 耐药网-标本类型
                      sOption = this.specimenOption;
                      break;
                  case "2": // 耐药网-细菌
                      sOption = this.germOption;
                      break;
                  case "3": // 耐药网-抗生素
                      sOption = this.medOption;
                      break;
                  case "4": // 耐药网-科室
                      sOption = this.deptOption;
                      break;
                  case "5": // 耐药网-仪器
                      sOption = this.instrumentOption;
                      break;
                  case "6": // 耐药网-药敏卡
                      sOption = this.medpanelOption;
                      break;
              }
              var optionitem = sOption.find((m) => m.codeno == row.carss_coden);
              console.info(optionitem);
              if (optionitem) {
                  return optionitem.codena;
              } else {
                  return "";
              }
          }
      },

      btnset() {
          this.dialogSetting = true;
      },
      // 中间件数据库连接设置 保存
      dialogflag_saveevent() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS813",
                  method: "post",
                  data: {
                      action: "saveset",
                      dbms: this.dbms,
                      server: this.Server,
                      database: this.DataBase,
                      logid: this.Logid,
                      password: this.Password,
                      dbparm: this.DbParm,
                      istest: "0",
                  },
              })
              .then((res) => {
                  if (res.flag == "1") {
                      this.dialogSetting = false;
                      this.initOption();
                  } else {
                      this.$alert(res.msg, "异常", {
                          confirmButtonText: "确定",
                      });
                      return false;
                  }
              })
              .catch(() => {});
      },
      dialogflag_cancelevent() {
          this.dialogSetting = false;
      },
      dialogflag_testevent() {
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS813",
                  method: "post",
                  data: {
                      action: "saveset",
                      dbms: this.dbms,
                      server: this.Server,
                      database: this.DataBase,
                      logid: this.Logid,
                      password: this.Password,
                      dbparm: this.DbParm,
                      istest: "1",
                  },
              })
              .then((res) => {
                  if (res.flag == "1") {
                      this.$alert("连接正常！");
                      //this.dialogSetting = false;
                  } else {
                      this.$alert(res.msg, "异常", {
                          confirmButtonText: "确定",
                      });
                      return false;
                  }
              })
              .catch(() => {});
      },

      opendialog(row, num) {
          this.isshow = parseInt(num);
          this.selrow = row;
          this.drn_itemdialog = true;
      },

      drnitemchange(code, name) {
          this.selrow.carss_coden = code;
          this.selrow.carss_codename = name;
          setTimeout(() => {
              this.$refs.xTable1.setCurrentRow(this.selrow);
          }, 30);
          this.drn_itemdialog = false;
          this.changeflag = true;
      },

      // 保存页签变化数据
      savetabdata(tabno, newtabno) {
          let tabledata = [];
          switch (parseInt(tabno)) {
              case 0:
                  tabledata = this.$refs.xTable1.getRecordset();
                  break;
              case 1:
                  tabledata = this.$refs.xTable2.getRecordset();
                  break;
              case 2:
                  tabledata = this.$refs.xTable3.getRecordset();
                  break;
              case 3:
                  tabledata = this.$refs.xTable4.getRecordset();
                  break;
              case 4:
                  tabledata = this.$refs.xTable5.getRecordset();
                  break;
              default:
                  break;
          }
          if (tabledata.updateRecords.length == 0) {
              this.oldtabno = newtabno;
              this.InitTabPage();
              return;
          }
          this.$tool
              .request({
                  url: "LIS/LIS8/LIS813",
                  method: "post",
                  data: {
                      action: "savetabdata",
                      tabno: tabno,
                      tabdata: tabledata,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$message({
                          message: "操作成功！",
                          type: "success",
                      });
                      this.specimenNum = 0;
                      this.germNum = 0;
                      this.medNum = 0;
                      this.deptNum = 0;
                      this.instrumentNum = 0;
                      this.medpanelNum = 0;
                      this.oldtabno = newtabno;
                      this.changeflag = false;
                      this.InitTabPage();
                  } else {
                      this.$message({
                          message: "保存失败！" + response.errmsg,
                          type: "warning",
                      });
                  }
              });
      },

      btnSave() {
          this.savetabdata(this.isshow, this.isshow);
          // let tabledata1 = this.$refs.xTable1.getRecordset();
          // let tabledata2 = this.$refs.xTable2.getRecordset();
          // let tabledata3 = this.$refs.xTable3.getRecordset();
          // let tabledata4 = this.$refs.xTable4.getRecordset();
          // let tabledata5 = this.$refs.xTable5.getRecordset();
          // // let tabledata6 = this.$refs.xTable6.getRecordset();

          // this.$tool
          //     .request({
          //         url: "LIS/LIS8/LIS813",
          //         method: "post",
          //         data: {
          //             action: "save",
          //             specimendata: tabledata1,
          //             germdata: tabledata2,
          //             meddata: tabledata3,
          //             deptdata: tabledata4,
          //             instrumentdata: tabledata5,
          //             // medpaneldata: tabledata6,
          //         },
          //     })
          //     .then((response) => {
          //         if (response.errcode == "1") {
          //             this.$message({
          //                 message: "操作成功！",
          //                 type: "success",
          //             });
          //             this.specimenNum = 0;
          //             this.germNum = 0;
          //             this.medNum = 0;
          //             this.deptNum = 0;
          //             this.instrumentNum = 0;
          //             this.medpanelNum = 0;
          //             this.InitTabPage();
          //         } else {
          //             this.$message({
          //                 message: "保存失败！" + response.errmsg,
          //                 type: "warning",
          //             });
          //         }
          //     });
      },
      btnContrast() {
          switch (parseInt(this.isshow)) {
              case 0:
                  this.tableData1.tableData.forEach((item) => {
                      if(item.carss_coden == "" || item.carss_coden == null){
                      var optionitem = this.specimenOption.filter((m) => m.codeno == item.specimen_code || m.codena == item.specimen_name);
                      if (optionitem.length > 0 ) {
                          item.carss_coden = optionitem[0].codeno;
                          item.carss_codename = optionitem[0].codena;
                          this.specimenNum++;
                      }}
                  });
                  break;
              case 1:
                  this.tableData2.forEach((item) => {
                      if(item.carss_coden == "" || item.carss_coden == null){
                      var optionitem = this.germOption.filter((m) => m.codena.indexOf(item.rpt_itemname) != -1 || m.codeno == item.itemcode_en);
                      if (optionitem.length > 0 ) {
                          item.carss_coden = optionitem[0].codeno;
                          item.carss_codename = optionitem[0].codena;
                          this.germNum++;
                      }
                      }
                  });
                  break;
              case 2:
                  this.tableData3.forEach((item) => {
                      if(item.carss_coden == "" || item.carss_coden == null){
                      var optionitem = this.medOption.filter((m) => m.codeno == item.medcode || m.codena == item.medname);
                      if (optionitem.length > 0 ) {
                          item.carss_coden = optionitem[0].codeno;
                          item.carss_codename = optionitem[0].codena;
                          this.medNum++;
                      }}
                  });
                  break;
              case 3:
                  this.tableData4.tableData.forEach((item) => {
                      if(item.carss_coden == "" || item.carss_coden == null){
                      var optionitem = this.deptOption.filter((m) => m.codeno == item.deptno || m.codena == item.deptname);
                      if (optionitem.length > 0 ) {
                          item.carss_coden = optionitem[0].codeno;
                          item.carss_codename = optionitem[0].codena;
                          this.deptNum++;
                      }}
                  });
                  break;
              case 4:
                  this.tableData5.tableData.forEach((item) => {
                      if(item.carss_coden == "" || item.carss_coden == null){
                      var optionitem = this.instrumentOption.filter((m) => m.codeno == item.instrno || m.codena == item.instrname);
                      if (optionitem.length > 0 ) {
                          item.carss_coden = optionitem[0].codeno;
                          item.carss_codename = optionitem[0].codena;
                          this.instrumentNum++;
                      }}
                  });
                  break;
              default:
                  this.tableData6.tableData.forEach((item) => {
                      if(item.carss_coden == "" || item.carss_coden == null){
                      var optionitem = this.medpanelOption.filter((m) => m.codeno == item.testgroupno || m.codena == item.testgroupname);
                      if (optionitem.length > 0 && item.carss_coden == null) {
                          item.carss_coden = optionitem[0].codeno;
                          item.carss_codename = optionitem[0].codena;
                          this.medpanelNum++;
                      }}
                  });
                  break;
          }
          this.changeflag = true;
          //this.dialogcontrast = true;
      },
      dialogcontrast_save() {
          this.dialogcontrast = false;
          this.btnSave();
      },
      dialogcontrast_cancel() {
          this.dialogcontrast = false;
      },

      searchdata() {
          let filterName = this.txtsearch.trim();
          let filterlist = [];
          switch (parseInt(this.isshow)) {
              case 0:
                  if (filterName) {
                      filterlist = this.oldtableData1.filter((item) => {
                          return item.specimen_code.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.specimen_name ? item.specimen_name.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                      });
                  } else {
                      filterlist = this.oldtableData1;
                  }
                  this.tableData1 = filterlist;
                  break;
              case 1:
                  if (filterName) {
                      filterlist = this.oldtableData2.filter((item) => {
                          return item.rpt_itemcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.rpt_itemname ? item.rpt_itemname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                      });
                  } else {
                      filterlist = this.oldtableData2;
                  }
                  this.tableData2 = filterlist;
                  break;
              case 2:
                  if (filterName) {
                      filterlist = this.oldtableData3.filter((item) => {
                          return item.medcode.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.medname ? item.medname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                      });
                  } else {
                      filterlist = this.oldtableData3;
                  }
                  this.tableData3 = filterlist;
                  break;
              case 3:
                  if (filterName) {
                      filterlist = this.oldtableData4.filter((item) => {
                          return item.deptno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.deptname ? item.deptname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                      });
                  } else {
                      filterlist = this.oldtableData4;
                  }
                  this.tableData4 = filterlist;
                  break;
              case 4:
                  if (filterName) {
                      filterlist = this.oldtableData5.filter((item) => {
                          return item.instrno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.instrname ? item.instrname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                      });
                  } else {
                      filterlist = this.oldtableData5;
                  }
                  this.tableData5 = filterlist;
                  break;
              default:
                  if (filterName) {
                      filterlist = this.oldtableData6.filter((item) => {
                          return item.testgroupno.toUpperCase().indexOf(filterName.toUpperCase()) > -1 || (item.testgroupname ? item.testgroupname.toUpperCase().indexOf(filterName.toUpperCase()) > -1 : false);
                      });
                  } else {
                      filterlist = this.oldtableData6;
                  }
                  this.tableData6 = filterlist;
                  break;
          }
      },
  },
};
</Script>

<style scoped>
.pagetop {
  width: 100%;
  height: 45px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 50px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 0px;
  overflow: auto;
}

.table1style tr td {
  padding: 0px 2px 0px 2px;
}

.trstyle {
  height: 50px;
}
.tdstyle1 {
  width: 60px;
}

.tdstyle2 {
  text-align: right;
  width: 80px;
  color: blue;
}

.search-title {
  margin: 0 5px 0 20px;
  font-size: 12px;
}

/deep/ .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}

.top-deal {
  right: 5px;
  position: absolute;
  top: 10px;
  display: flex;
  align-items: center;
}
/deep/ tr.vxe-body--row.row-modify {
  color: blue;
}
/deep/ tr.vxe-body--row.row-new {
  color: #cc6600;
}
</style>